package org.meandslava.calc.arithmetic;

import static org.meandslava.calc.arithmetic.Term.*;

public class TermFactory {
	
	public static Term create(String termCatAndTag){
		String[] catAndTag = termCatAndTag.split(":");
		if(catAndTag.length == 2){
			return create(catAndTag[0], catAndTag[1]);
		}
		return null;
	}
	
	public static Term create(String termCat, String termTag){
		if(termCat.equals(CATEGORY_UNARY)){
			return new Unary(termTag);
		}else if(termCat.equals(CATEGORY_BINARY)){
			return new Binary(termTag);
		}else if(termCat.equals(CATEGORY_FIXED_NUMBER)){
			return new FixedNumber(termTag);
		}else if(termCat.equals(CATEGORY_EXPRESSION)){
			return new Expression();
		}
		return null;
	}
}
